<template>
  <div id="customerCenterIndex">
    <c-title :hide="false" text="我的客户"></c-title>
    <diyBackGround></diyBackGround>
    <div class="main">
      <div class="topHead" v-if="datainfo.member">
        <div class="imageBox">
          <img :src="datainfo.member.avatar_image" alt="" />
        </div>
        <div class="right">
          <div class="rightTop">
            <div class="name">{{ datainfo.member.nickname }}</div>
            <div class="leave" v-if="datainfo.member.level_name">{{ datainfo.member.level_name }}</div>
          </div>
          <div class="rightId">
            <div class="ID">ID：{{ datainfo.member.uid }}</div>
            <div class="codeInvitation">
              邀请码：{{ datainfo.member.invite_code }}
              <div class="img" v-clipboard:copy="datainfo.member.invite_code" v-clipboard:success="onCopy">
                <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FcustomerCenter%2Fimage1%402x.png" alt="" />
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="otherBox">
        <div class="plugBox" v-if="datainfo.plugins">
          <div class="plug" v-for="(item, index) in datainfo.plugins" :key="index" @click="toPlugin(item.plugin_name)">
            <!-- <i class="iconfont" :class="item.class ? item.class : ''"></i> -->
             <img :src="item.background" alt="" style="width: 1.5rem;">
            <div class="name">{{ item.title }}</div>
          </div>
        </div>
        <div class="dataBox" v-if="datainfo.referral">
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.child_total }}</div>
            <div class="name">客户数量（人）</div>
          </div>
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.team_total }}</div>
            <div class="name">总客户数（人）</div>
          </div>
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.today_amount }}</div>
            <div class="name">今日收入（元）</div>
          </div>
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.child_order_money }}</div>
            <div class="name">客户订单（元）</div>
          </div>
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.team_order_money }}</div>
            <div class="name">总客户订单（元）</div>
          </div>
          <div class="dataLis">
            <div class="num">{{ datainfo.referral.total_amount }}</div>
            <div class="name">累计收入（元）</div>
          </div>
        </div>
      </div>
      <div class="shareBox" v-if="datainfo.open_user_info_button && datainfo.member && datainfo.member.superior_info">
        <div class="title">分享人</div>
        <div class="userBox">
          <div class="image">
            <img :src="datainfo.member.superior_info.avatar_image" alt="" />
          </div>
          <div class="detailRight">
            <div class="name">
              {{ datainfo.member.superior_info.nickname }}
              <div class="leave" v-if="datainfo.member.superior_info.level_name">{{ datainfo.member.superior_info.level_name }}</div>
            </div>
            <div class="id" v-if="datainfo.member.superior_info.uid">ID：{{ datainfo.member.superior_info.uid }}</div>
            <div class="bottom">
              <div class="mobile" v-if="datainfo.member.superior_info.mobile">电话：{{ datainfo.member.superior_info.mobile }}</div>
              <div class="rightBottom">
                <div class="rightBottom_image">
                  <i class="iconfont icon-card_weixin1" v-if="datainfo.member.superior_info.wechat" v-clipboard:copy="datainfo.member.superior_info.wechat" v-clipboard:success="onCopy"></i>
                  <i class="iconfont icon-card_phone" @click="telCall(datainfo.member.superior_info.mobile)" v-if="datainfo.member.superior_info.mobile"></i>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="nav">
        <div class="navli" @click="tapNav(0)" :class="navInd == 0 ? 'navBg' : ''">直推客户{{ datainfo.referral ? `(${datainfo.referral.child_total})` : "" }}</div>
        <div class="navli" @click="tapNav(1)" :class="navInd == 1 ? 'navBg' : ''">间推客户{{ datainfo.referral ? `(${datainfo.referral.indirect_team})` : "" }}</div>
      </div>
      <div class="contenBox">
        <div class="searchBox">
          <div class="searchBox_left">
            <van-field v-model="searchKey" @keydown.enter='getList' placeholder="会员ID/姓名/昵称/手机号" />
            <div class="posSearchBnt" @click="getList">
              <i class="iconfont icon-sousuo1"></i>
            </div>
          </div>
          <div class="searchBox_right" @click="goTrack" v-show="datainfo.open_browse_footprint">轨迹追踪</div>
        </div>
        <div class="searchNavLis">
          <div class="searchNav" @click.stop="setShowInd(0)">
            <div class="name">{{ level_id && level_id.id ? level_id.name : "会员等级" }}</div>
            <i class="iconfont icon-ht_more_bottom"></i>
          </div>
          <div class="searchNav" @click.stop="setShowInd(1)" style="flex: 1.2;">
            <div class="name">{{ is_agent ? "推广员" : is_agent == '0' ? '不是推广员' : '是否为推广员' }}</div>
            <i class="iconfont icon-ht_more_bottom"></i>
          </div>
          <div class="searchNav" @click.stop="setShowInd(2)" style="flex: 1.2;">
            <div class="name">{{ orderby.name }}</div>
            <i class="iconfont icon-ht_more_bottom"></i>
          </div>
          <div class="searchNav" @click.stop="setShowInd(3)">
            <div class="name">{{ browse && browse.id ? browse.name : "轨迹" }}</div>
            <i class="iconfont icon-ht_more_bottom"></i>
          </div>
        </div>
        <div class="record">
          <searchRecord :info="list" :set="display_set" :open_browse_footprint="datainfo.open_browse_footprint" :open_user_info_button ="datainfo.open_user_info_button "></searchRecord>
        </div>
      </div>
    </div>
    <van-popup v-model="show" round position="bottom">
      <van-picker v-if="showIndex == 0" :title="setTitle" value-key="level_name" show-toolbar :columns="userLeave" @confirm="onConfirm" @cancel="onCancel" @change="onChange" />
      <van-picker v-else :title="setTitle" value-key="name" show-toolbar :columns="selectOption" @confirm="onConfirm" @cancel="onCancel" @change="onChange" />
    </van-popup>
  </div>
</template>
<script>
import customerCenterIndex_controller from "./customerCenterIndex_controller";

export default customerCenterIndex_controller;
</script>
<style lang="scss" scoped>
@keyframes ident {
  0% {
    opacity: 0;
  }

  50% {
    opacity: 0.75;
  }

  100% {
    opacity: 1;
  }
}

.main {
  margin: 0 0.75rem;
  margin-top: -8.75rem;

  .contenBox {
    margin-top: 1.25rem;
    border-radius: 8px;
    background: #fff;
    padding: 1rem 0.75rem;

    .searchNavLis {
      display: flex;

      .searchNav {
        flex: 1;
        display: flex;
        align-items: center;
        margin: 0.75rem 0;
        justify-content: center;
        overflow: hidden;
        padding-right: 0.125rem;
        box-sizing: border-box;

        .name {
          max-width: 100%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          font-size: 0.75rem;
        }

        .iconfont {
          flex-shrink: 0;
          color: #dbdbdb;
          font-size: 0.35rem;
          margin-left: 0.2rem;
        }
      }
    }

    .searchBox {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .searchBox_left {
        flex: 1;
        // position: relative;
        background: #f6f6f6;
        display: flex;
        justify-content: space-between;

        .van-cell {
          padding: 0.375rem 0.75rem;
          line-height: normal;
          background: #f6f6f6;
        }

        .posSearchBnt {
          // position: absolute;
          // right: 0;
          // top: 0;
          padding: 0.375rem 0;
          width: 3rem;
          height: 100%;
          border-radius: 1.125rem;
          background: var(--themeBaseColor);
          display: flex;
          align-items: center;
          justify-content: center;

          .iconfont {
            color: #fff;
          }
        }
      }

      .searchBox_right {
        flex-shrink: 0;
        padding: 0.375rem 1rem;
        margin-left: 0.625rem;
        border: 1px solid var(--themeBaseColor);
        color: var(--themeBaseColor);
        font-size: 0.75rem;
        border-radius: 1.125rem;
      }
    }
  }

  .nav {
    margin: 1rem;
    background: #fff;
    border-radius: 1.125rem;
    height: 2.25rem;
    display: flex;
    align-items: center;

    .navli {
      flex: 1;
      height: 100%;
      line-height: 2.25rem;
      border-radius: 1.125rem;
    }

    .navBg {
      background: var(--themeBaseColor) !important;
      background-image: none;
      color: #fff;
      animation: ident 1s;
    }
  }

  .shareBox {
    padding: 1rem 0.75rem;
    background: #fff;
    margin-top: 0.75rem;

    .title {
      font-size: 0.9375rem;
      font-weight: bold;
      color: #333;
      text-align: left;
    }

    .userBox {
      display: flex;
      margin-top: 0.8125rem;

      .image {
        width: 2.75rem;
        height: 2.75rem;
        background: #000;
        border-radius: 1.375rem;
        margin-right: 0.5rem;

        img {
          width: 100%;
          height: 100%;
          border-radius: 100%;
        }
      }

      .detailRight {
        display: flex;
        flex-direction: column;
        flex: 1;

        .name {
          display: flex;
          border-radius: 0.75rem;

          .leave {
            font-size: 0.625rem;
            border-radius: 0.75rem;
            padding: 0.125rem 0.25rem;
            background: var(--themeBaseColor);
            color: #fff;
            margin-left: 0.25rem;
          }
        }

        .id {
          font-size: 0.75rem;
          color: #999;
          text-align: left;
        }

        .bottom {
          display: flex;
          align-items: center;

          .mobile {
            font-size: 0.75rem;
            color: #999;
            text-align: left;
          }

          .rightBottom {
            flex: 1;

            .rightBottom_image {
              width: 100%;
              display: flex;
              justify-content: flex-end;

              .iconfont {
                font-size: 1.2rem;
                color: var(--themeBaseColor);
              }

              .icon-card_weixin1 {
                margin-right: 0.625rem;
              }
            }
          }
        }
      }
    }
  }

  .otherBox {
    margin-top: 1.25rem;
    padding: 1rem 0.625rem;
    border-radius: 0.5rem;
    background: #fff;

    .dataBox {
      border-radius: 0.25rem;
      padding: 1rem 0;
      background: #fff9e8;
      margin-top: 0.75rem;
      display: flex;
      flex-wrap: wrap;
      padding: 1rem 0.8125rem;
      justify-content: space-between;

      .dataLis {
        width: 30%;
        text-align: center;
        margin-bottom: 1rem;
        overflow: hidden;

        .num {
          font-size: 0.875rem;
          font-weight: bold;
          color: #333;
          text-align: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        .name {
          font-size: 0.6875rem;
          color: #999;
          text-align: center;
          margin-top: 0.25rem;
          white-space: nowrap;
        }
      }

      .dataLis:nth-child(n + 3) {
        margin-bottom: 0;
      }
    }

    .plugBox {
      display: flex;

      .plug {
        width: 25%;

        .name {
          font-size: 0.875rem;
          color: #333;
        }

        .iconfont {
          display: inline-block;
          margin: 0 auto 0.3125rem auto;
          margin-bottom: 0;
          width: 1.5rem;
          height: 1.5rem;
        }
      }
    }
  }

  .topHead {
    display: flex;
    justify-content: space-between;

    .right {
      flex: 1;

      .rightTop {
        display: flex;
        margin-bottom: 0.25rem;

        .name {
          font-size: 1.125rem;
          font-weight: bold;
          color: #fff;
          margin-right: 0.25rem;
        }

        .leave {
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 0.625rem;
          padding: 0.125rem 0.25rem;
          box-sizing: border-box;
          border-radius: 0.75rem;
          background: var(--themeBaseColor);
          color: #fff;
        }
      }

      .rightId {
        display: flex;
        font-size: 0.75rem;
        color: #fff;

        .codeInvitation {
          display: flex;
          align-items: center;

          .img {
            width: 1rem;
            height: 1rem;
            margin-left: 0.25rem;

            img {
              width: 100%;
              height: 100%;
            }
          }
        }

        .ID {
          margin-right: 1rem;
        }
      }
    }

    .imageBox {
      flex-shrink: 0;
      width: 2.75rem;
      height: 2.75rem;
      background: rgba(0, 0, 0, 0);
      border-radius: 100%;
      margin-right: 0.5rem;

      img {
        width: 100%;
        height: 100%;
        border-radius: 100%;
      }
    }
  }
}
</style>